package com.example.liwushuo.adapter;

import java.util.List;

import com.example.liwushuo.BaseApp;
import com.example.liwushuo.R;
import com.example.liwushuo.bean.Channel_groups;
import com.example.liwushuo.bean.Channels;



import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

public class GridVieAdapter extends BaseAdapter {

	private List<Channels> list;
	
	private LayoutInflater inflater;

	public GridVieAdapter(Context context, List<Channels> list) {
		this.list = list;
		inflater = LayoutInflater.from(context);

	}

	@Override
	public int getCount() {
		return list.size();
	}

	@Override
	public Object getItem(int position) {
		return list.get(position);
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {

		ViewHolder holder;
		if (convertView == null) {
			convertView = inflater.inflate(R.layout.gridview_item,null);
			holder = new ViewHolder();
			holder.img = (ImageView) convertView.findViewById(R.id.sort_icon);
			holder.imgname = (TextView) convertView.findViewById(R.id.sort_imgname);
			//holder.title=(TextView) convertView.findViewById(R.id.sort_name);
			convertView.setTag(holder);
		} else {

			holder = (ViewHolder) convertView.getTag();
		}

		BaseApp.getBitmapUtils().display(holder.img, list.get(position).getIcon_url());
		holder.imgname.setText(list.get(position).getName());
		return convertView;
		
	
	}

	private static class ViewHolder {
		ImageView img;
		TextView imgname,title;

	}
}
